package nabaixin.com.net.protocol;

import nabaixin.com.utils.Constant;
import android.content.Context;
import android.util.Log;

public class RegisterProtocol extends BaseProtocol {
	private static final String TAG = "RegisterProtocol-->";
	
	private String email;
	private String password;
	private String nickname;
	private String birthday;
	private String gender;
	private String province;
	private String city;
	
	private String packedStr;
	private String encodeStr;
	
	public RegisterProtocol(String email, String password, String neckname,
			String birthday, String gender, String province, String city) {
		this.email = email;
		this.password = password;
		this.nickname = neckname;
		this.birthday = birthday;
		this.gender = gender;
		this.province = province;
		this.city = city;
	}

	@Override
	public void packData() {
		//REG [TRID] 100 email=xxx&pwd=xxx&nickname=xxx&gender=xxx&birth=xxx&province=xxx&city=xxx&ver=xxx
		StringBuffer sb = new StringBuffer();
		sb.append("REG ").append(Constant.TRID_REGISTER).append(" 100 ")
			.append("email=").append(email)
			.append("&pwd=").append(password)
			.append("&nickname=").append(nickname)
			.append("&gender=").append(gender)
			.append("&birth=").append(birthday)
			.append("&province=").append(province)
			.append("&city=").append(city)
			.append("&ver=").append(Constant.VER);
		packedStr = sb.toString();
		Log.d(Constant.TAG, TAG+packedStr);
	}

	@Override
	public void excute(Context context) {
		encodeStr = encodeData(packedStr, TAG);
		sendData(context, encodeStr);
	}
	
}
